package org.restly.representations;

import org.restly.*;
import org.restly.core.ContentType;

import java.io.IOException;

/**
 * Oct 25, 2008, 6:06:49 AM
 *
 * @author <a href="http://restly.org/">Erik Beeson</a>
 */
public class StringRepresentation implements Representation {
	private final String s;

	public StringRepresentation(String s) {
		this.s = s;
	}

	public void represent(org.restly.servlet.RestlyContext context, org.restly.servlet.RestlyHttpServletRequest request, org.restly.servlet.RestlyHttpServletResponse response) throws IOException {
		response.setContentType(ContentType.TEXT_PLAIN);
		try {
			response.getWriter().println(s);
		} catch(IOException e) {
			e.printStackTrace();
		}
	}
}
